<template>
	<div id="returnwork">
		<el-form ref="form" :model="form" label-width="80px">
			<el-form-item label="活动区域">
				<el-select v-model="form.selectedNodeID" placeholder="请选择活动区域">
					<el-option
						v-for="item in returnData"
						:key="item.No"
						:label="item.RecName + item.Name"
						:value="item.No+'@'+item.Rec"
					></el-option>
				</el-select>
			</el-form-item>
			<el-form-item label="活动形式">
				<el-input type="textarea" v-model="form.doc"></el-input>
			</el-form-item>
			<el-form-item>
				<el-button @click="onSubmit">确定返回</el-button>
				<el-button @click="onSubmit">返回后并发送给我</el-button>
				<el-button>关闭</el-button>
			</el-form-item>
		</el-form>
	</div>
</template>

<script>
export default {
	name: "returnwork",
	props: {
		data: String
	},
	data() {
		return {
			form: {
				selectedNodeID: "",
				doc: ""
			},
            returnData: [],
            isBack:false,
            params:{}
		};
	},

	beforeCreate() {},

	created() {
        console.log("退回窗口", this.data);
        this.params = this.$store.getters.getData;
		this.returnData = JSON.parse(this.data);
	},

	mounted() {},

	methods: {
		onSubmit() {
			console.log("submit!");
			console.log(this.form);
			if (!this.form.selectedNodeID) {
				this.$message({
					message: "请选择要退回的节点",
					type: "warning"
                });
                return;
            }
            if (!this.form.doc) {
				this.$message({
					message: "请输入退回原因",
					type: "warning"
                });
                return;
            }

            this.params.ReturnToNode = this.form.selectedNodeID;
            this.params.ReturnInfo = this.form.doc;
            this.params.IsBack = this.isBack
            console.log("this.params",this.params);
            var handler = new this.HttpHandler("BP.WF.HttpHandler.WF_WorkOpt");
            handler.AddJson(this.params);
            //调用退回方法.
            var data = handler.DoMethodReturnString("DoReturnWork"); //执行方法.
            console.log("退回执行返回",data);
            if (data.indexOf('err@') == 0) {
                alert("退回按钮初始化接口返回数据还有错误，需要弹出信息22");
                //console.error("退回窗口错误信息" + data);
                // data = data.replace('err@', '');
                // data = "<font color=red>" + data + "</font>";
                // $("#Msg").html(data);
                // //  alert(data);
                return;
            }
            this.$message({
                message: data,
                type: 'success'
            });

            this.$Bus.$emit("closeMsg","退回")
		}
	},

	//监听
	computed: {},

	components: {},

	//监听后执行动作
	watch: {}
};
</script>

<style lang="less" scoped>
</style>